package com.photoeditor.demo.util;

import android.app.Activity;

import com.common.base.ComponentContext;
import com.photoeditor.R;
import com.photoeditor.demo.model.store.module.BaseOnlineManager;
/**
 * Created by Administrator on 2017/10/27 0027.
 */

public class PluginVersionUtil {

    /**
     * 插件版本说明
     *
     * 1. 默认所有资源版本从1开始，小于1的当1处理（老版本数据库没配置版本）
     * 2. 模板主包支持版本升级-->2  PE1.12增加动态模板插件
     * 3. 模板主包支持版本升级-->3  PC1.03动态模板插件支持连续png播放动画
     **/

    /**
     * 校验插件版本是否可用，若不可用时，弹出升级弹窗
     * @param activity
     * @param type {@link BaseOnlineManager#STORE_FUNC_TYPE_FILTER}
     * @param pluginVersion
     * @return
     */
    public static boolean verifyPluginVersion(Activity activity, int type, int pluginVersion) {
        boolean ret = true;
//        int curVersion = 0;
//        switch (type) {
//            case BaseOnlineManager.STORE_FUNC_TYPE_FILTER:
//                curVersion = getFilterPluginVersionCode();
//                break;
//        }
//        if (pluginVersion > curVersion) {
//            ret = false;
//            new PluginVersionUtil.GPUpdateDialog(activity).show();
//        }
        return ret;
    }

    public static int getStickerPluginVersionCode() {
        return ComponentContext.getContext().getResources().getInteger(R.integer.plugin_version_sticker);
    }

    public static int getFilterPluginVersionCode() {
        return ComponentContext.getContext().getResources().getInteger(R.integer.plugin_version_filter);
    }

    public static int getMagazinePluginVersionCode() {
        return ComponentContext.getContext().getResources().getInteger(R.integer.plugin_version_magazine);
    }

    public static int getBackgroundPluginVersionCode() {
        return ComponentContext.getContext().getResources().getInteger(R.integer.plugin_version_background);
    }

    public static int getPluginSupportShowVersionCode() {
        return ComponentContext.getContext().getResources().getInteger(R.integer.plugin_display_version);
    }
}
